#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for(int b = 0; b < 30; b++) {
        vector<ll> cnt(2);
        vector<ll> sumO(2);
        int x = 0;
        ll cur = 0;
        cnt[0] = 1;
        for(int i = 0; i < n; i++) {
            x ^= ((a[i] >> b) & 1);
            ll sum = (cnt[x ^ 1] * (i + 1)) % MOD;
            cur = (cur + ((sum - sumO[x ^ 1]) + MOD) % MOD) % MOD;
            cnt[x]++;
            sumO[x] = (sumO[x] + (i + 1)) % MOD;
        }
        ans = (ans + (1 << b) * cur) % MOD;
    } 
    cout << ans << endl;
}


int main() {
    solve();
    return 0;
}